/* Copyright (c) 2011 Alexandre Défossez
 * This file is part of HINAPT.
 *
 * HINAPT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * HINAPT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HINAPT.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "CameraThread.hpp"

CameraThread::CameraThread(VideoCapture &capture, ThQueue<std::pair<Mat, double> > &queue,
                           bool &stop):
  capture(capture), queue(queue), stop(stop) {}


void CameraThread::Run(){
  Mat img;
  while(!stop){
    getImage(capture, img);

    std::pair<Mat, double> pair(img, globalClock.GetElapsedTime());
    queue.push(pair);
    sf::Sleep(0.);// Permet de rendre la main à l'ordonnanceur
    // Et ainsi de permettre plus rapidemment l'exécution d'un autre thread.
  }

}
